package com.common.enums;


import com.common.domain.ErrorCode;

public interface GlobalErrorCodeConstants {

    ErrorCode SUCCESS = new ErrorCode(0, "成功");

    // ========== 客户端错误段 ==========
    ErrorCode SJHCW = new ErrorCode(300, "手机号错误");
    ErrorCode YHYBZC = new ErrorCode(301, "手机号已被注册");
    ErrorCode SJH_NO_SUPPORT = new ErrorCode(302, "手机号格式错误");
    ErrorCode NOTEINVALID = new ErrorCode(303,"验证码已过期");
    ErrorCode YZM_ERROR = new ErrorCode(304,"验证码错误！");


    ErrorCode BAD_REQUEST = new ErrorCode(400, "请求参数不正确");
    ErrorCode UNAUTHORIZED = new ErrorCode(401, "账号未登录");
    ErrorCode FORBIDDEN = new ErrorCode(403, "没有该操作权限");
    ErrorCode NOT_FOUND = new ErrorCode(404, "请求未找到");
    ErrorCode METHOD_NOT_ALLOWED = new ErrorCode(405, "请求方法不正确");
    ErrorCode LOCKED = new ErrorCode(423, "请求失败，请稍后重试");
    ErrorCode TOO_MANY_REQUESTS = new ErrorCode(429, "请求过于频繁，请稍后重试");

    // ========== 服务端错误段 ==========

    ErrorCode INTERNAL_SERVER_ERROR = new ErrorCode(500, "系统异常");

    // ========== 自定义错误段 ==========
    ErrorCode REPEATED_REQUESTS = new ErrorCode(900, "重复请求，请稍后重试");
    ErrorCode DEMO_DENY = new ErrorCode(901, "演示模式，禁止写操作");

    ErrorCode UNKNOWN = new ErrorCode(999, "未知错误");

   static boolean isMatch(Integer code) {
       return code != null
               && code >= SUCCESS.getCode() && code <= UNKNOWN.getCode();
   }

}
